#include <iostream>
#include <thread>
#include <windows.h>
#include <vector>
using namespace std;
using namespace std::this_thread;

void msg(int num)
{
	cout << endl;
	std::thread::id thread_id = get_id();
	cout <<num<<"="<< thread_id << endl;
}

//c++多线程
void cpp_thread()
{
	//获取cpu数量
	auto n = thread::hardware_concurrency();
	std::cout << n << std::endl;

	//获取当前线程id
	std::thread::id thread_id = get_id();
	cout << thread_id << endl;

	////创建线程
	//thread t1(msg);
	//thread t2(msg);
	//t1.join();
	//t2.join();

	vector<thread *> threads;
	for (int i = 0; i < 5; i++)
	{
		threads.push_back( new thread(msg,i));
	}

	for (auto th : threads)
	{
		th->join();

	}


}



void main8()
{
	cpp_thread();
	cin.get();
}